const { msg } = require("./alert");

cc.Class({
    extends: cc.Component,

    properties: {
        bgMusic:cc.AudioClip,
    },

    onLoad() {
        cc.game.addPersistRootNode(this.node);
        this.playBgMusic();
    },

    
    playBgMusic() {
        this.stopBgMusic();
       this.bgMusicChannel = cc.audioEngine.play(this.bgMusic,true,0.5);
    },
    stopBgMusic() {        
        if (this.bgMusicChannel !== undefined) {
            cc.audioEngine.stop(this.bgMusicChannel);            
            this.bgMusicChannel = undefined;
        }
    },

});